Skip to content

feat(ws): support enableReceivedNotification in SignatureSubscribe#432

Open
ozpool wants to merge 1 commit into
solana-foundation:mainfrom
ozpool:feat/ws-signaturesubscribe-received-notification
Open

feat(ws): support enableReceivedNotification in SignatureSubscribe#432
ozpool wants to merge 1 commit into
solana-foundation:mainfrom
ozpool:feat/ws-signaturesubscribe-received-notification

Conversation

@ozpool
Copy link
Copy Markdown

@ozpool ozpool commented May 14, 2026

Summary

Adds SignatureSubscribeWithOpts + SignatureSubscribeOpts to mirror the optional configuration object the signatureSubscribe RPC method accepts, including the missing enableReceivedNotification flag.

When enableReceivedNotification: true, the validator emits an extra notification with value: "receivedSignature" as soon as the transaction enters its mempool, in addition to the final value: { err: ... } status notification. Today the SDK can't ask for that flag and the SignatureResult.Value struct can't decode the string variant if the user enables it on the RPC side themselves.

What changed

  • SignatureResult.Value is now a named SignatureValue with a custom UnmarshalJSON that dispatches on the wire shape:
    • JSON object {"err": ...} -> populates Err
    • JSON string "receivedSignature" -> sets ReceivedSignature = true
    • null is treated as a no-op
    • any other JSON / unknown string marker is a decode error
  • SignatureSubscribeOpts { Commitment, EnableReceivedNotification } plus SignatureSubscribeWithOpts(signature, opts) carry the new flag through to the request body.
  • The existing SignatureSubscribe(signature, commitment) entry point is preserved by delegating to the new opts form, and result.Value.Err access continues to work unchanged.

Test plan

  • go build ./...
  • go test ./...
  • New signatureSubscribe_test.go covers: status with err: null, status with non-null err, "receivedSignature" string variant, unknown-marker rejection, null no-op

Add SignatureSubscribeWithOpts and SignatureSubscribeOpts, mirroring the
optional configuration object the signatureSubscribe RPC method accepts.
EnableReceivedNotification opts the subscription into the additional
"received" notification the validator emits as soon as the transaction
enters its mempool, in addition to the final status notification.

The notification value can now arrive as either a status object
({"err": ...}) or the literal string "receivedSignature". A new
SignatureValue named type with a custom UnmarshalJSON dispatches on
JSON shape so the existing result.Value.Err access keeps working and
the new ReceivedSignature field surfaces the marker variant. The
existing SignatureSubscribe entry point delegates to the new opts
form, preserving its (signature, commitment) signature.

Adds unit coverage for both notification shapes, the null/empty case,
and an unknown-marker rejection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant